<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>经营报表</title>
		<link rel="stylesheet" href="dist/css/layui.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/shouy.css" />
	</head>

	<body>
		<div class="wrap">
			<div class="sy_header clearfix">
				<div class="sy_hleft">
					<div class="sy_logobox">
						<div class="sy_logo"><img src="img/logo-ma.png"></div>
						<p id="app_name"></p>
					</div>
					<ul class="sy_nav clearfix">
						<li>
							<a href="index.html">
								<div class="iconfont icon-shouyintai"></div>
								<p>桌台点餐</p>
							</a>
						</li>
						<li >
							<a href="reserve.html">
								<div class="iconfont icon-saomashouyin"></div>
								<p>预订管理</p>
							</a>
						</li>
						<li>
							<a href="deal_order.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>交易查询</p>
							</a>
						</li>
						<li class="active">
							<a  href="xiaof_member.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>会员管理</p>
							</a>
						</li>
						<li>
							<a href="xiaof_member.html">
								<div class="iconfont icon-weibiaoti-"></div>
								<p>交班</p>
							</a>
						</li>
					</ul>
				</div>
				<div class="sy_shopbox">
					<div class="sy_simg"><img id="toux" src="" style="background-color: #FFFFFF;"></div>
					<div class="sy_sinfo">
						<p class="sy_snam">店名：<span id="sname"></span></p>
						<p>用户：<span id="user">15973240090</span></p>
						<p class="exit" onclick="exit()">退出登陆</p>
					</div>
				</div>
			</div>

			<div class="sy_xconbox clearfix">
				<div class="sy_xftop clearfix">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">会员手机</label>
							<div class="layui-input-inline">
								<input type="text" id="sn" placeholder="请输入会员手机" name="sn" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">交易时间</label>
							<div class="layui-input-inline" style="width: 120px;">
								<input  ignore type="text" placeholder="yyyy-mm-dd" name="date" id="start_time" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid">-</div>
							<div class="layui-input-inline" style="width: 120px;">
								<input  ignore type="text" placeholder="yyyy-mm-dd" name="date1" id="end_time" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<button type="button" id="search" class="sy_jybtn">搜索</button>
						</div>

					</div>
				</div>
				<div class="sy_spcenter">
					<table class="layui-table">
						<colgroup>
							<col width="100">
							<col width="100">
							<col width="100">
							<col width="100">
							<col width="100">
							<col width="100">
							<col width="100">
							<col width="100">
							<col>
						</colgroup>
						<thead>
							<tr>
								<th>会员名称(ID)</th>
								<th>联系方式</th>
								<th>会员级别</th>
								<th>账户余额</th>
								<th>累计充值</th>
								<th>消费金额</th>
								<th>注册时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="mem_body">
						</tbody>
					</table>
					<div id="demo2" style="text-align: center;"></div>
				</div>
			</div>
		</div>
		
		<script type="text/javascript" src="dist/jquery-1.11.0.min.js"></script>
		<script src="dist/layui.all.js"></script>
		<script src="dist/json2.js"></script>
		<script src="datepicker/WdatePicker.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script>
			

			
			if(!getValue("store_name_id")) {
				location.href = 'login.html';
			}
			$(function() {
				set_info();
				load_dt();
			})
			$("#search").click(function() {
				var order_sn = $("#sn").val();
				var start_time = $("#start_time").val();
				var end_time = $("#end_time").val();
				load_dt(1, order_sn, start_time, end_time)

			})
			$("#export").click(function() {
				var begin = $("#start_time").val();
				var end = $("#end_time").val();
				var str = "&begin_time=" + begin + "&end_time=" + end;
				window.location.href = APP.api_url + "sy/export?chain_id=" + getValue("chain_id") + str;
			})
			
		function show_cz(){
			var html='<div class="payment">'+
				'<div class="payment_erweima">'+
					'<div id="qrcode"><img src="img/cz.png"/></div>'+
				'</div>'+
			'</div>';
				layer.open({
							title: '扫码充值',
							shadeClose: false,
							shade: 0.8,
							btn: false,
							area: ['300px', '400px'],
							content: html
					});
			}
			function load_dt(page, order_sn, start_time, end_time) {
				layui.use(['laypage', 'layer'], function() {
					var laypage = layui.laypage,
						layer = layui.layer;
					var index = layer.load(1, {
						shade: [0.1, '#fff'] //0.1透明度的白色背景
					});
					$.ajax({
						url: APP.api_url + "Sy/get_member_list",
						data: {
							page: page,
							mobile:order_sn,
							start_time: start_time,
							end_time: end_time,
							app_id	:APP.app_id,
							time:Date.parse( new Date())
						},
						success: function(data) {
							var mems = data.user_list;
							var count = data.count;
							if(mems) {
								var tr=""; 
								for(var m in mems) {
									var log = mems[m];
									
									var balance = log['balance']?log['balance']:0;
									var recharge_money = log['recharge_money']?log['recharge_money']:0;
									var consume_money = log['consume_money']?log['consume_money']:0;
									var level_name=log['level_name'];
									if(level_name==null){
									 level_name="";
									}
									tr += '<tr><td>' + log["user_name"]+'('+log["id"]+')' + '</td>' +
										'<td>' + log['mobile'] + '</td>' +
										'<td>' + level_name + '</td>' +
										'<td>' + balance + '</td>' +
										'<td>' + recharge_money + '</td>' +
										'<td>' + consume_money + '</td>' +
										'<td>' + log['add_time'] + '</td>' +
										'<td><a href="javascript:show_cz()">充值</a></td>'+
										'</tr>';
									
								}
								$("#mem_body").html(tr);
								layer.close(index);
								//调用分页
								laypage.render({
									elem: 'demo2',
									count: count,
									limit: 7,
									jump: function(obj, first) {
										//模拟渲染
										var curr = obj.curr;
										if(!first) {
											get_reports(curr);
										}
									}
								});
							}

						}
					})

				});

			}

			function get_reports(page) {
				$.ajax({
					url: APP.api_url + "Sy/get_member_list",
						data: {
							page: page,
							mobile:order_sn,
							start_time: start_time,
							end_time: end_time,
							app_id	:APP.app_id,
							time:Date.parse( new Date())
						},
					success: function(data) {
						var mems = data.paylog_list;
						var count = data.count;
							if(mems) {
								var tr=""; 
								for(var m in mems) {
									var log = mems[m];
									
									var balance = log['balance']?log['balance']:0;
									var recharge_money = log['recharge_money']?log['recharge_money']:0;
									var consume_money = log['consume_money']?log['consume_money']:0;
									var level_name=log['level_name'];
									if(level_name==null){
									 level_name="";
									}
									tr += '<tr><td>' + log["user_name"]+'('+log["id"]+')' + '</td>' +
										'<td>' + log['mobile'] + '</td>' +
										'<td>' + level_name + '</td>' +
										'<td>' + balance + '</td>' +
										'<td>' + recharge_money + '</td>' +
										'<td>' + consume_money + '</td>' +
										'<td>' + log['add_time'] + '</td>' +
										'<td><a href="javascript:show_cz()">充值</a></td>'+
										'</tr>';
									
								}
								$("#mem_body").html(tr);
								layer.close(index);
								//调用分页
								laypage.render({
									elem: 'demo2',
									count: count,
									limit: 7,
									jump: function(obj, first) {
										//模拟渲染
										var curr = obj.curr;
										if(!first) {
											get_reports(curr);
										}
									}
								});
						}
					}
				})
			}
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate;
				//日期
				laydate.render({
					elem: '#start_time'
				});
				laydate.render({
					elem: '#end_time'
				});

			});
			
		</script>

	</body>

</html>